package io.gitee.vexlife.snakeagentexample;

import java.util.Random;

import io.gitee.vexlife.snake.GameController;
import io.gitee.vexlife.snake.IAgent;
import io.gitee.vexlife.snake.SnakeAgent;
import io.gitee.vexlife.snake.basic.Direction;

@SnakeAgent(name="随机玩家")
public class RandomPlayer implements IAgent {

	private GameController gmctrl;

	@Override
	public void step() {
		int decision = new Random().nextInt(3);
		switch (decision) {
		case 0:
			this.gmctrl.getSnake().turn(Direction.LEFT);
			break;
		case 1:
			this.gmctrl.getSnake().turn(Direction.RIGHT);
			break;
		}
	}

	@Override
	public void initAgent(GameController gmctrl) {
		this.gmctrl = gmctrl;
	}

}